<include file="public/header" title="取消订单" body="g4"/>
<include file="public/header_nav" title="取消订单" href="javascript:history.back(-1);"/>
<form id='cancelForm'>
    <input type="hidden" class="text gray" name="order_id" value="{$order['order_id']}"/>
    <input type="hidden" class="text gray user_note" name="user_note" value=""/>
    <div class="n_hadgetgoods">
        <div class="reminder">
            <div class="maleri30 bop">
                <div class="message">
                    <p>温馨提示：</p>
                    <p>1.限时特价、预约资格等购买优惠可能一并取消</p>
                    <p>2.如遇订单拆分、使用优惠券无法返还</p>
                    <p>3.支付金额，抵扣余额积分都按原路退款</p>
                    <p>4.订单一旦取消，无法恢复</p>
                </div>
            </div>
        </div>
        <div class="resonalist list7 detailsfloo">
            <div class="maleri30">
                <div class="myorder returnreson p">
                    <a href="javascript:void(0)">
                        <div class="order">
                            <div class="fl">
                                <span class="firde">退款原因：</span>
                                <span id="user_note">订单不能按预计时间送达</span>
                            </div>
                            <div class="fr">
                                <i class="Mright"></i>
                            </div>
                        </div>
                    </a>
                </div>

                <div class="myorder p">
                    <span class="tp-left-label">联 系 人 : </span>
                    <input class="tp-right-cont" type="text" name="consignee" id="consignee" value="{$order['consignee']|default=$user['nickname']}">
                </div>
                <div class="myorder p">
                    <span class="tp-left-label">手 机 号 : </span>
                    <input class="tp-right-cont" type="text" name="mobile" id="mobile" value="{$order['mobile']}">
                </div>
            </div>
        </div>

        <div class="applyandreyurn ma-to-30">
            <a href="javascript:;" onclick="btnSubmit()">申请退款</a>
        </div>
    </div>
    <div class="y_hadgetgoods">
        <div class="reminder">
            <div class="maleri30 bop">
                <div class="message">
                    <p>若您对已收到的货的商品质量不满意，您可以提交返修/退换货申请，订单状态将自动设置为"已完成"</p>
                </div>
            </div>
        </div>
        <div class="reminder reminder_r">
            <div class="maleri30">
                <div class="message">
                    <p>您的商品已出库，订单拦截可能不成功，您可到订单详情页关注最新进度。</p>
                </div>
            </div>
        </div>
        <div class="applyandreyurn ma-to-30">
            <a href="">申请返修/退换货</a>
        </div>
    </div>
    <!--取消订单-s-->
    <div class="losepay closeorder">
        <div class="maleri30">
            <div class="l_top">
                <span>取消原因</span>
                <em class="turenoff"></em>
            </div>
            <div class="resonco">
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>订单不能按预计时间送达</span>
                    </span>
                </div>
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>操作有误(商品、地址等选错)</span>
                    </span>
                </div>
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>重复下单/误下单</span>
                    </span>
                </div>
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>其他渠道价格更低</span>
                    </span>
                </div>
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>该商品降价了</span>
                    </span>
                </div>
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>不想买了</span>
                    </span>
                </div>
                <div class="radio">
                    <span class="che">
                        <i></i>
                        <span>其他原因</span>
                    </span>
                </div>
            </div>
        </div>
        <a href="javascript:;" onclick="btnConfirm()"><div class="submits_de">确定</div></a>
    </div>
    <!--取消订单-e-->
</form>
<div class="mask-filter-div" style="display: none;"></div>
<script type="text/javascript">
    $(function(){
        //弹出层
        $('.returnreson').click(function(){
            $('.mask-filter-div').show();
            $('.losepay').show();
        });
        $('.turenoff').click(function(){
            $('.mask-filter-div').hide();
            $('.losepay').hide();
        });
        //未/已收到货切换
        $('.item_ask_2 .n').click(function(){
            $(this).addClass('action').siblings().removeClass('action');
            $('.n_hadgetgoods').show();
            $('.y_hadgetgoods').hide();
        });
        $('.item_ask_2 .y').click(function(){
            $(this).addClass('action').siblings().removeClass('action');
            $('.n_hadgetgoods').hide();
            $('.y_hadgetgoods').show();
        });
        $('.che').on('click', function() {
           if ($(this).hasClass('check_t')) {
               $('.check_t').removeClass('check_t');
               $(this).addClass('check_t');
           }
           if ($('.check_t').length > 0) {
               $('.submits_de').addClass('bagrr');
           } else {
               $('.submits_de').removeClass('bagrr');
           }
        });
        $('.turenoff').on('click', function () {
            if ($('.check_t span').text() !== '') {
                var user_note = $('.check_t span').text();
                $('#user_note').text(user_note);
                $('.user_note').val(user_note);
            }
        });
    });

    function btnSubmit() {
        $.ajax({
            url:"{:U('Order/record_refund_order')}",
            method:'POST',
            data: {
                'order_id' : "{$order['order_id']}",
                'user_note' : $('#user_note').text(),
                'consignee' : $('#consignee').val(),
                'mobile' :    $('#mobile').val()
            },
            dataType:'json',
            error: function () {
//                layer.open({content:"服务器繁忙, 请联系管理员!", time:2});
            },
            success: function (data) {
                console.log(data);
                if (data.status === 1) {
                    layer.open({content:data.msg, time:2});
                    location.href = "{:U('Order/order_list')}";
                } else {
                    layer.open({content:data.msg, time:2});
                }
            }
        });
    }
    function btnConfirm() {
        if ($('.submits_de').hasClass('bagrr')) {
            $('.turenoff').click();
        }
    }
</script>
</body>
</html>
